from skimage import io, data, color, draw
import numpy as np

# read an image and show
img = io.imread("images/lena_contrast.png")
io.imshow(img)
io.show()

# write and save an image
io.imsave("images/temp.png", img)

# data module provides some standard test images
io.imshow(data.camera())
io.show()
io.imshow(data.text())
io.show()
io.imshow(data.astronaut())
io.show()

# color module can change the color space
grayscale_img = color.rgb2gray(color.rgba2rgb(img))
io.imshow(grayscale_img)
io.show()
hsv_img = color.rgb2hsv(data.astronaut())
io.imshow(hsv_img)
io.show()

# draw module can draw different shapes
img2 = np.zeros((100, 100), dtype=np.uint8)
x, y = draw.circle_perimeter(50, 50, 10)
img2[x, y] = 1
io.imshow(img2)
io.show()
img3 = np.zeros((100, 100), dtype=np.uint8)
x, y = draw.ellipse_perimeter(50, 50, 10, 20)
img3[x, y] = 1
io.imshow(img3)
io.show()
img4 = np.zeros((100, 100), dtype=np.uint8)
r = np.array([10, 25, 80, 50])
c = np.array([10, 60, 40, 10])
x, y = draw.polygon_perimeter(r, c)
img4[x, y] = 1
io.imshow(img4)
io.show()
